﻿@using hc.epm.DataModel.Business;
@using System.Collections.Generic;
@using hc.epm.Common
@using hc.Plat.Common.Extend;
@model List<Epm_Monitor>
@{
    ViewBag.Title = "安全检查列表";
}

<div class="contentData">
    <div class="form-select c">
        <form method="get">
            <div>
                <div>
                    <label>项目名称 : </label>
                    <input type="text" name="ProjectName" id="ProjectName" value="@ViewBag.ProjectName">
                    <input type="hidden" name="ProjectId" id="ProjectId" value="@ViewBag.ProjectId">
                </div>
                <div><label>检查标题 : </label> <input type="text" id="Title" name="Title" value=""></div>
                <div>
                    <label>状态 : </label>
                    @Html.DropDownList("state", ViewBag.CheckState as SelectList)
                </div>
            </div>
            <div class="form-sub">
                <button type="button" id="add" class="checkright" data-module="QualityCheck" data-right="Add">新 增</button>
                <button type="submit" class="checkright" data-module="QualityCheck" data-right="Browse">查 询</button>
            </div>
        </form>
    </div>
    <div>
        <table class="datalist" style="word-break:break-all;word-wrap:break-word">
            <thead>
                <tr>
                    <th width="30">序号</th>
                    <th width="120">项目名称</th>
                    <th width="130">检查标题</th>
                    <th>检查内容</th>
                    <th width="100">创建单位</th>
                    <th width="50">检查人员</th>
                    <th width="100">检查时间</th>
                    <th width="80">状态</th>
                    <th width="110">操作</th>
                </tr>
            </thead>
            <tbody>
                @{
                    int index = (ViewBag.pageIndex - (ViewBag.pageIndex - 1)) * ((ViewBag.pageIndex - 1) * 10);
                }
                @if (Model != null && Model.Count() > 0)
            {
                foreach (var item in Model)
                {
                    index++;
                        <tr>
                            <td style="display:none">
                                <input type="hidden" class="inputId" data-id="@item.Id" />
                            </td>
                            <td>@index</td>
                            <td>@item.ProjectName</td>
                            <td>@item.Title</td>
                            <td>@item.Content</td>
                            <td>@item.MonitorCompanyName</td>
                            <td>@item.MonitorUserName</td>
                            <td>@(item.MonitorTime == null ? "" : Convert.ToDateTime(item.MonitorTime).ToString("yyyy-MM-dd"))</td>
                            @if (item.State == int.Parse(CheckState.WaitCheck.GetValue().ToString()))
                            {
                                <td class="state">@CheckState.WaitCheck.GetText()</td>
                                <td>
                                    <a href="javascript:;" class="Detail checkright" data-module="QualityCheck" data-right="Info">查看</a>
                                    <a href="javascript:;" class="edit checkright" data-module="QualityCheck" data-right="Modify">修改</a>
                                    <a href="javascript:;" class="Delete checkright" data-module="QualityCheck" data-right="Delete">删除</a>
                                    <a href="javascript:;" class="exchange">沟通</a>

                                </td>
                            }
                            else if (item.State == int.Parse(CheckState.CheckSuccess.GetValue().ToString()))
                            {
                                <td class="state">@CheckState.CheckSuccess.GetText()</td>
                                <td>
                                    <a href="javascript:;" class="Detail checkright" data-module="QualityCheck" data-right="Info">查看</a>
                                    <a href="javascript:;" class="exchange">沟通</a>
                                </td>

                            }
                            else if (item.State == int.Parse(CheckState.Rectification.GetValue().ToString()))
                            {
                                <td class="state">@CheckState.Rectification.GetText()</td>
                                <td>
                                    <a href="javascript:;" class="Detail checkright" data-module="QualityCheck" data-right="Info">查看</a>
                                    <a href="javascript:;" class="exchange">沟通</a>
                                    @if (item.RectificationResult != RectificationState.Rectificationed.ToString())
                                    {
                                    <a href="javascript:" class="submitAQ checkright" data-module="QualityCheck" data-right="MonitorRectif">整改</a>
                                    }
                                </td>
                            }
                            else if (item.State == int.Parse(CheckState.UpdateOk.GetValue().ToString()))
                            {
                                <td class="state">@CheckState.UpdateOk.GetText()</td>
                                <td>
                                    <a href="javascript:;" class="Detail checkright" data-module="QualityCheck" data-right="Info">查看</a>
                                    <a href="javascript:;" class="exchange">沟通</a>
                                </td>
                            }
                        </tr>
                    }
                }
                else {
                    <tr>
                        <td colspan="10" class="table-center">
                            暂无数据
                        </td>
                    </tr>
                }


            </tbody>
        </table>
    </div>
    <div id="page" style="text-align:right; margin-right:5px;">
    </div>
</div>
<script>
    //若无数据隐藏分页组件
    if ('@ViewBag.Total' == 0) {
        $("#page").hide();
    }
    layui.use(['layer', 'element', 'laypage'], function () {
        var layer = layui.layer, element = layui.element, $ = layui.jquery, laypage = layui.laypage;
        //分页
        laypage.render({
            elem: 'page',
            count: '@ViewBag.Total',
            curr: '@ViewBag.pageIndex',
            layout: ['prev', 'page', 'next', 'skip', 'count'],
            jump: function (obj, first) {
                if (!first) {
                    //得到了当前页，用于向服务端请求对应数据
                    var curr = obj.curr;
                    var search = $("form").serialize();
                    window.location.href = "/QualityMonitor/IndexZL?pageIndex=" + curr + "&" + search;
                }
            }
        });
    });
    //新增
    $("#add").on("click", function () {
        window.location.href = "/QualityMonitor/AddZL";
    });
    //查看
    $("tbody").on("click", ".Detail", function () {
        var id = $(this).parents("tr").find($(".inputId")).data("id");
        window.location.href = "/QualityMonitor/DetailZL?id=" + id;
    });
    //删除
    $("tbody").on("click", ".Delete", function () {
        var id = $(this).parents("tr").find($(".inputId")).data("id");
        if (id != "") {
            parent.layer.confirm("确认要删除所选择的项？", { icon: 3 }, function () {
                $.post("Delete", { id: id }, function (data) {
                    if (data.Flag) {
                        parent.layer.msg("删除成功", { time: 1000, icon: 1 });
                        window.location.href = "/QualityMonitor/IndexZL?pageIndex=1";
                    } else {
                        parent.layer.alert(data.Message, { icon: 2 });
                    }
                }, "json");
            }, function () {
                return;
            })
        } else {
            parent.layer.alert("请先选择要删除的数据", { icon: 2 });
        }
    });
    //修改
    $("tbody").on("click", ".edit", function () {
        var id = $(this).parents("tr").find($(".inputId")).data("id");
        window.location.href = "/QualityMonitor/EditZL?id=" + id;
    });
    //上传整改结果
    $("tbody").on("click", ".submitAQ", function () {
        var id = $(this).parents("tr").find($(".inputId")).data("id");
        window.location.href = "/QualityMonitor/UploadRectifyResultZL?id=" + id;
    });
    //沟通
    $('tbody').on('click', '.exchange', function () {
        window.location.href = "/Question/Add?businType=QualityCheck&BusinessId=" + $(this).parents("tr").find($(".inputId")).data("id");
    });
</script>










